package com.demo.test.controller;

import com.demo.test.entity.Sing;
import com.demo.test.entity.SingVo;
import com.demo.test.entity.User;
import com.demo.test.service.ISingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.concurrent.locks.Condition;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author XieHuan
 * @since 2017-06-10
 */
@Controller
@RequestMapping("/sing")
public class SingController {

    @Autowired
    private ISingService iSingService;

    /**
     * 只是查询状态为1的歌手
     * @return
     */
    @RequestMapping("/allSingsByType")
    @ResponseBody
    public List<Sing> allByType(){
        return iSingService.selectAllSingByType();
    }

    /**
     * 只是查询状态为1的歌手
     * @return
     */
    @RequestMapping("/allSing")
    @ResponseBody
    public List<Sing> all(){
        return iSingService.selectList(null);
    }

    @RequestMapping("/updateSingShutdoun")
    @ResponseBody
    public boolean updateSingShutdoun(@RequestBody Sing  sing){
        sing.setSingtype("0");
      boolean t=iSingService.updateById(sing);

        return t;
    }

    @RequestMapping("/updateSingOpen")
    @ResponseBody
    public boolean updateSingOpen(@RequestBody Sing sing){
        sing.setSingtype("1");
        return iSingService.updateById(sing);
    }

    @RequestMapping("/addSings")
    @ResponseBody
    public boolean addSings(Sing sing){

        boolean i=iSingService.insert(sing);
        return i;
    }
    @RequestMapping("/selectSingsByPiaoShu")
    @ResponseBody
    public List<SingVo> selectSingsByPiaoShu(){
        return iSingService.selectSingsByPiaoShu();
    }


}
